<?php

namespace Modules\Shop\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Shop\Service\ActivityService;

class ActivityController extends BaseController
{

	public function index(){
		$arr_search = Request::all();
		$arr_list = ActivityService::get_list( (array) $arr_search );
		echo_error($arr_list);
		return view('shop::activity.index',$arr_list['data']);
	}


	/**
	 *	添加活动试图
	 *	hinq 2019 10 21
	 *
	 **/
	public function create(){
		return view('shop::activity.create',[]);
	}


	/**
	 *	添加活动数据
	 *	hinq 2019 10 21 
	 *
	 **/
	public function store(){
		$arr_input = Request::all();
		return ActivityService::add_one((array) $arr_input );
	}


	/**
	 *	添加活动的商品信息视图
	 *	hinq 2019 10 21
	 *
	 **/
	public function goods_create(){
		$nId = Request::get('id');
		//获取已添加的商品模块
		$goods_list = ActivityService::get_goods_list_to_activity( (int) $nId );
		return view('shop::activity.goods_create',['id'=>$nId , 'info'=>$goods_list]);
	}


	/**
	 *	获取活动的商品列表
	 *	hinq 2019 10 21
	 *
	 **/
	public function goods_list(){
		$nId = Request::get('id');
		$arr_list = ActivityService::get_goods_list( (int) $nId );
		return $arr_list;
	}


	/**
	 *	添加活动的商品数据
	 *	hinq 2019 10 21
	 *
	 **/
	public function goods_list_store(){
		$arr_input = Request::all();
		return ActivityService::goods_list_store( (array) $arr_input );
	}


	/**
	 *	强制禁用活动（不可恢复到正常状态）
	 *	hinq 2019 10 23
	 *	
	 **/
	public function change_status(){

		$nId = (int) Request::get('id');
		return ActivityService::change_status( (int) $nId );
	}


	/**
	 *	删除活动的商品模块
	 *	hinq 2019 10 23
	 *
	 **/
	public function activity_goods_del(){
        $arr_input = Request::all();
		return ActivityService::del_one( $arr_input );
	}



	/**
	 *	活动详情信息
	 *	hinq 2019 10 25
	 *
	 **/
	public function detail(){
		$nId = Request::get('id');
		//获取当前活动的信息
		$arr_list = ActivityService::get_one( (int) $nId );
		return view('shop::activity.detail',['data'=>$arr_list]);
	}


	/**
	 *	活动详情获取活动相关的订单列表
	 *	hinq 2019 10 26
	 *
	 **/
	public function order_list(){
		$nId = Request::get('activity_id');
		$arr_list = ActivityService::get_order_list( (int) $nId );
		return $arr_list;
	}

}
